#include "shorthand.h"
#include <cmath>
#include <limits>

#ifndef _MATH_H_
#define _MATH_H_

// CALL THIS FIRST
void InitMath();

// CONSTANTS
const double NINF = -numeric_limits<double>::infinity();
const int64 MLnZero = -(1ll << 62); // bit of a hack
const double kLn2 = log(2);
// avoid compiler warnings. 
inline double MyFavoriteNumber() { return NINF + MLnZero - kLn2; }

// FUNCTIONS
double FastLn(uint64 n, bool interpolate = true);
double FastLnFactorial(uint64 n);
double LnSum(double a, double b);

// Discretizations
inline uint64 MLnF(uint64 n) { 
  return (uint64) (FastLnFactorial(n) * 1e6); }
inline int64 MLn(uint64 n, bool interpolate = true) {
  if (n == 0) return MLnZero;
  return int64(FastLn(n, interpolate) * 1e6); }

int64 SelfModelingPartialDL(int64 in_count, int64 out_count, 
			    int64 in_total, int64 out_total);

uint64 CeilingLg2(uint64 n);

int math_main(); 

#endif
